package cn.wolfcode.service.impl;

import cn.wolfcode.domain.RecordLog;
import cn.wolfcode.mapper.RecordLogMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IRecordLogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecordLogServiceImpl implements IRecordLogService {

    @Autowired
    private RecordLogMapper recordLogMapper;


    @Override
    public void save(RecordLog recordLog) {
        recordLogMapper.insert(recordLog);
    }

    @Override
    public void delete(Long id) {
        recordLogMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(RecordLog recordLog) {
        recordLogMapper.updateByPrimaryKey(recordLog);
    }

    @Override
    public RecordLog get(Long id) {
        return recordLogMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<RecordLog> listAll() {
        return recordLogMapper.selectAll();
    }

    @Override
    public PageInfo<RecordLog> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize()); //对下一句sql进行自动分页
        List<RecordLog> recordLogs = recordLogMapper.selectForList(qo); //里面不需要自己写limit
        return new PageInfo<RecordLog>(recordLogs);
    }
}
